<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加药品信息</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">


  <script src="../../layui-v2.5.5/layui/layui.all.js"></script>
  <script src="../../layui-v2.5.5/layui/css/layui.css"></script>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
            <td valign="bottom" class="title">添加药品信息</td>
          </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="">
<table width="95%"  border="0" cellpadding="0" cellspacing="0">


  <tr>
    <td width="90" align="center" class="td_form01">药房</td>
    <td colspan="3" class="td_form02">
      <select class="phaname">
        <option value="1">药房A</option>
        <option value="2">药房B</option>
        <option value="3">药房C</option>

      </select>
    </td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">药品名称</td>
    <td colspan="3" class="td_form02"><input class="drugname" type="text"></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">药品数量</td>
    <td colspan="3" class="td_form02"><input class="drugnumber" type="text"></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">药品单价</td>
    <td colspan="3" class="td_form02"><input class="drugprice" type="text"></td>
  </tr>


  <tr>
    <td width="90" align="center" class="td_form01">药品类别</td>
    <td colspan="3" class="td_form02">
      <select class="druname">
        <option value="1">片剂</option>
        <option value="2">胶囊剂</option>
        <option value="3">注射剂</option>

      </select>
    </td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">生产日期</td>
    <td colspan="3" class="td_form02"><input name="textfield" type="date" class="drugdate"></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">有效期</td>
    <td colspan="3" class="td_form02"><input name="textfield" type="text" class="dugperiod">个月</td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">库存单位</td>
    <td colspan="3" class="td_form02">
      <select class="pridunit">
        <option value="1">箱</option>
        <option value="2">盒</option>
        <option value="3">瓶</option>

      </select>
    </td>
  </tr>


  <tr>
    <td width="90" align="center" class="td_form01">药品报警日期</td>
    <td colspan="3" class="td_form02"><input name="textfield" type="date" class="drugplidate"></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">药品报警值</td>
    <td colspan="3" class="td_form02"><input class="drugplival" type="text"></td>
  </tr>
</table>
  <br>
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center"><input name="Submit" type="button" class="add" value=" 添加">
        <input name="Submit" type="button" class="close" onClick="window.close()" value="  关闭  "></td>
    </tr>
  </table>
  </form>
</center>
</body>
</html>
<script src="../../js/jquery.js">
</script>
<script>
<!--绑定按钮单击事件，发送添加药品需要的信息-->
$(".add").on("click",function () {
  $.ajax({
    url:"/feign/drugStorageController/addDrugInfo",
    type:"post",
    headers: {
      Accept: "application/json; charset=utf-8",
      Authorization: location.href.split("=")[1]
    },
    data:{"phaid":$(".phaname").val(),"drugname":$(".drugname").val(),"drugnumber":$(".drugnumber").val(),
      "drugprice":$(".drugprice").val(),"druname":$(".druname option:selected").text(),"drugdate":$(".drugdate").val(),
      "dugperiod":$(".dugperiod").val(),"pridunit":$(".pridunit option:selected").text(),"prid":$(".pridunit").val(),
      "drugplidate":$(".drugplidate").val(),"drugplival":$(".drugplival").val(),"druid":$(".druname").val()},

    dataType: "text",
    success:function (data) {
      console.log("药品响应信息："+data);
      if(data=="fail"){
        layer.msg("添加失败，请重新输入")
      }else{
        layer.msg("添加成功")
        show()
      }

    }
  })
})
var timeout = 4;
function show() {
  var showbox = $(".showbox");
  showbox.html(timeout);
  timeout--;
  if (timeout == 0) {
    window.opener = null;
    window.close();
  }
  else {
    setTimeout("show()", 1000);
  }
}
</script>
